//
//  CGTabBarController.m
//  SchoolClient
//
//  Created by mac on 15/10/27.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGTabBarController.h"

@interface CGTabBarController ()

@end

@implementation CGTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initChildViewControllers];
    
}

-(void)initChildViewControllers{
    
    //首页
    CGHomePageViewController *homeVC = [CGHomePageViewController new];
    //设置底部导航按钮的属性
    [self setupChildViewController:homeVC withImage:[UIImage imageNamed:@"tabbar_home"] andSelectedImage:[UIImage imageNamed:@"tabBar_home_selected"] andTitle:@"首页"];
    UINavigationController *homeNav = [[UINavigationController alloc]initWithRootViewController:homeVC];
    [self addChildViewController:homeNav];
    
    //企业
    CGEnterpriseViewController *enterpriseVC = [CGEnterpriseViewController new];
    [self setupChildViewController:enterpriseVC withImage:[UIImage imageNamed:@"tabbar_enterprise"] andSelectedImage:[UIImage imageNamed:@"tabBar_enterprise_selected"] andTitle:@"社会招聘"];
    UINavigationController *enterpriseNav = [[UINavigationController alloc]initWithRootViewController:enterpriseVC];
    [self addChildViewController:enterpriseNav];
    
    //学校
    CGSchoolViewController *schoolVC = [CGSchoolViewController new];
    [self setupChildViewController:schoolVC withImage:[UIImage imageNamed:@"tabbar_school"] andSelectedImage:[UIImage imageNamed:@"tabbar_school_selected"] andTitle:@"校园招聘"];
    UINavigationController *schoolNav = [[UINavigationController alloc]initWithRootViewController:schoolVC];
    [self addChildViewController:schoolNav];
    
    //我的
    CGMineViewController *mineVC = [CGMineViewController new];
    [self setupChildViewController:mineVC withImage:[UIImage imageNamed:@"tabbar_mine"] andSelectedImage:[UIImage imageNamed:@"tabbar_mine_selected"] andTitle:@"我的"];
    UINavigationController *mineNav = [[UINavigationController alloc]initWithRootViewController:mineVC];
    [self addChildViewController:mineNav];
    
}

-(void)setupChildViewController:(UIViewController *)childVC
                      withImage:(UIImage *)image
               andSelectedImage:(UIImage *)selectedImage
                       andTitle:(NSString *)title{

    childVC.title = title;
    childVC.tabBarItem.image = image;
    childVC.tabBarItem.selectedImage = selectedImage;

}


@end
